package threadTesting;

import util.Vector;

/**
 * Created by IntelliJ IDEA.
 * User: s32465
 * Date: 09.11.2010
 * Time: 19:18:45
 * To change this template use File | Settings | File Templates.
 */
public class WriteVectorRunnable implements Runnable {
    private Vector vector;


    public WriteVectorRunnable(Vector vector) {
       
        this.vector = vector;
    }

    public void run() {
        for (int i = 0; i < this.vector.length(); i++) {
            while(WaitReadWrite.getFlag()) {}
            float value = (float) Math.random();
            System.out.println("Write: " + value + " to position " + i);
            this.vector.setElement(i, value);
            WaitReadWrite.setFlag(true);

        }

    }
}
